/*
 * pcb.c
 *
 *  Created on: Feb 29, 2012
 *      Author: Christian
 */

#include <stdlib.h>
#include "pcb.h"

pcb* pcb_new(const int pid) {
	pcb* pcb_ptr = (pcb*) malloc(sizeof(pcb));
	pcb_ptr->pid = pid;
	pcb_ptr->next_step = 0;
	pcb_ptr->state = RUNNABLE;
	pcb_ptr->waiting_on = NONE;
	pcb_ptr->owns = -1;

	return pcb_ptr;
}

void pcb_set_runnable(pcb* pcb) {
	pcb->state = RUNNABLE;
	pcb->waiting_on = NONE;
}


void pcb_set_blocked(pcb* pcb, const int waiting_on) {
	pcb->state = BLOCKED;
	pcb->waiting_on = waiting_on;
}
